import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner cin = new Scanner(System.in);
        int a[] = new int[100];
        int n, tot = 0;
        while(true){
            n = cin.nextInt();
            if(n==0) break;
            a[tot++] = n;
        }
        for(int i=tot-1; i>=0; i--){
            System.out.print(a[i]+(i==0?"\n":" "));
        }
    }
}